<?php session_start(); ?>
<table width="535" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="583" height="10"><div class="Innerheading">Quiz</div></td>
  </tr>
  <tr>
    <td><div class="InnerDarkbox" id="InnerDarkbox">
<?php
require_once("../includes/user.php");
$user=new User;
$y_row=$user->getUserProfile($_SESSION['id']);
$date=date('Y-m-d');
$res=$user->query("select * from quiz_names where '$date' BETWEEN from_date AND to_date AND (year_id=0 OR year_id='$y_row[year]') AND active=1 ");
if(mysql_num_rows($res)>0)
{
?>
<table width="529" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="169" height="25" align="center" valign="middle" class="head">Quiz name</td>
    <td width="98" height="25" align="center" valign="middle" class="head">End Date</td>
    <td width="157" height="25" align="center" valign="middle" class="head">Score</td>
    <td width="105" height="25" align="center" valign="middle" class="head">Start quiz</td>
  </tr>
  	
	<?php
	while($row=mysql_fetch_array($res))
	{
		$his_res=$user->query("select * from quiz_history where quiz_id='$row[quiz_id]' AND profile_id='$_SESSION[id]'");
		?>
	<tr>
    <td height="25" align="center" valign="middle"><?php echo $row['quiz_name']; ?></td>
    <td height="25" align="center" valign="middle"><?php 
	$da=explode("-",$row['to_date']);
	echo $da[2].'/'.$da[1].'/'.$da[0]; ?></td>
   	<td height="25" align="center" valign="middle">
	<?php 
		if(mysql_num_rows($his_res)==0)
		{
			echo 'Not Attended';
		}
		else
		{
			$his_row=mysql_fetch_array($his_res);
			$pieces = explode("/", $his_row['result']);
			if($pieces[1]!="")
			{
				echo $pieces[0].' Out of '.$pieces[1];
			}
			else
			{
				echo $pieces[0];
			}
		}
	?>      </td>
<td height="25" align="center" valign="middle">
	<?php
 		if(mysql_num_rows($his_res)==0)
		{
	?>
   <input type="image" name="next" id="next" src="img/buttons/attend.gif" onclick="load_ques(<?php echo $row['quiz_id']; ?>)" />
	<?php
		} 
		else
		{
	?>
    <img src="img/status/success.png" width="16" height="16" />    
    <?php
	}
    ?>    </td>
  </tr>        
        <?php
	}
?>
</table>

<?php
}
else
{
?>
	<table width="416" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" valign="middle">There are no more pending quizes</td>
  </tr>
</table>
<?php
}
?></div></td>
  </tr>
</table>
